home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Automation / Scripts / Effect - Materialize Enter.js < prev    next >
Encoding:
JavaScript  |  2002-05-13  |  3.7 KB  |  116 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2002 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Mary Obelnicki
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17.  
  18. The following script creates a key frame animation effect on 
  19. the currently selected objects.
  20.  
  21. Function:
  22.     materalize(letters, frames, stagger, opacity, rotation, xdiff, ydiff, scale, forward, startNow) 
  23.     
  24. Arguments:
  25.     <letters> LMObject - an array of the objects to apply the 
  26.         effect. Does not have to be text objects.  It can be 
  27.         any LMObject.
  28.     <frames> integer - the length of the animation for each 
  29.         object
  30.     <stagger> integer - the number of frames to stagger the 
  31.         start of each animation
  32.     <opacity> integer - the opacity to end at
  33.     <rotation> integer - the rotation to end at
  34.     <xdiff>, <ydiff> integer - the x, y difference from the 
  35.         initial position to end at.  In screen coords.
  36.     <scale> integer - scale of original size to end at. 
  37.         1=same size, 2=double size 
  38.     <forward> boolean - stagger from first character or 
  39.         last character
  40.     <startNow> boolean - should the animation start now, at 
  41.         the current frame, or end now. 
  42.  
  43. ***************************************************************
  44. To change the behavior of this script, make your changes below
  45. ***************************************************************/
  46.  
  47. var objects = application.currentComposition.selection; 
  48.  
  49. materalize(objects,12, 2, 0, 0, 0, 0, 3, true, true); 
  50.  
  51. /***************************************************************
  52. DO NOT EDIT BELOW THIS LINE
  53. ***************************************************************/
  54.  
  55.  
  56.  
  57. function materalize(letters, frames, stagger, opacity, rotation, xdiff, ydiff, scale, forward, startNow) 
  58. {
  59.     if(letters.length < 1)
  60.     return;     
  61.     //the first frame of the animation
  62.     var frame0;
  63.     if (startNow)
  64.      frame0 = letters[0].currentFrame;
  65.     else
  66.     frame0 = letters[0].currentFrame - (stagger * (letters.length - 1) + frames); 
  67.  
  68.     for (i=0; i < letters.length; i++)
  69.     {
  70.     var cl; // the current letter
  71.     if (forward)
  72.         cl = letters[i];
  73.     else
  74.         cl = letters[letters.length -1 -i];
  75.  
  76.     //the original values
  77.     var xo = cl.position.x; 
  78.     var yo = cl.position.y;
  79.     var oriOpacity = cl.opacity; 
  80.     var oriRotation = cl.rotation;
  81.     var oriScalex = cl.scale.x; 
  82.     var oriScaley = cl.scale.y; 
  83.  
  84.     //turn on relevant stopwatches    
  85.     
  86.     if (opacity != oriOpacity)
  87.         cl.stopwatch.opacity = true;     
  88.     if (rotation != oriRotation) 
  89.         cl.stopwatch.rotation = true; 
  90.     if (scale !=1) 
  91.         cl.stopwatch.scale = true; 
  92.     
  93.     if((xdiff != 0) || (ydiff != 0))
  94.         cl.stopwatch.position = true; 
  95.     
  96.     //first frame
  97.     cl.currentFrame = frame0 + (i * stagger);
  98.     cl.position.x = xo + xdiff; 
  99.     cl.position.y = yo + ydiff; 
  100.     cl.opacity = opacity;
  101.     cl.rotation = rotation; 
  102.     cl.scale.x = oriScalex * scale; 
  103.     cl.scale.y = oriScaley * scale; 
  104.     
  105.     //last frame    
  106.     cl.currentFrame = frame0 + frames + (i * stagger);
  107.     cl.position.x = xo; 
  108.     cl.position.y = yo; 
  109.     cl.scale.x = oriScalex; 
  110.     cl.scale.y = oriScaley; 
  111.     cl.opacity = oriOpacity;
  112.     cl.rotation = oriRotation;
  113.     }
  114. }
  115.  
  116.